package praktikumid.w07.p3;

import java.awt.BorderLayout;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class Exercise {
	
	public static void main(String[] args) throws IOException {
		
		/*
		 * Data processing
		 */
		JSONParser p = new JSONParser();
		List<String> authors;
		authors = p.getAuthors();
		System.out.println(authors.size());
		
		/*
		 * GUI
		 */
		
		JFrame window = new JFrame();
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		window.setVisible(true);
		
		window.setTitle("Authors' list");
		window.setSize(500, 300);
		
		window.getContentPane().setLayout(new BorderLayout());
		
		JPanel panel = new JPanel();
		//window.getContentPane().add(panel, BorderLayout.CENTER);
		//window.getContentPane().add(panel, BorderLayout.WEST);
		window.getContentPane().add(panel, BorderLayout.EAST);
		panel.setVisible(true);
		panel.setBackground(Color.GRAY);
		panel.setSize(300,300);
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
		
		for (String str : authors) {
			JLabel author = new JLabel(str);
			panel.add(author);
		}
		//window.getContentPane().add(new JButton("Press me 1"));
		//window.getContentPane().add(new JButton("Press me 2"));
	}


}
